package com.translate.web.service.impl;

import com.translate.web.dao.PaymentApprovalPicMapper;
import com.translate.entity.PaymentApprovalPic;
import com.translate.web.param.contract.IPaymentApprovalPicAddParam;
import com.translate.web.service.IPaymentApprovalPicService;
import com.basic.service.impl.BaseServiceImpl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

@Service
public class PaymentApprovalPicServiceImpl extends BaseServiceImpl<PaymentApprovalPic>
		implements IPaymentApprovalPicService {
	public PaymentApprovalPicServiceImpl(PaymentApprovalPicMapper mapper) {
		super(mapper);
	}

	protected Class<PaymentApprovalPic> getEntityClass() {
		return PaymentApprovalPic.class;
	}

	@Override
	public <Param extends IPaymentApprovalPicAddParam> int batchInsert(List<Param> list, int paymentApprovalId, int receivablesId) {
		
		if (null == list) {
			return 0;
		}

		List<PaymentApprovalPic> ts = new ArrayList<>(); 
		
		PaymentApprovalPic pic;
		
		for (Param p : list) {
			
			pic = new PaymentApprovalPic();
			
			pic.setApprovalId(paymentApprovalId);
			
			pic.setPic(p.getPic());
			
			pic.setReceivablesId(receivablesId);
			
			ts.add(pic);
		}
		
		return this.batchInsert(ts);
	}
}